//package com.example.instantmessage.utils;
//
//import android.Manifest;
//import android.app.Activity;
//import android.content.pm.PackageManager;
//import android.os.Build;
//
//import androidx.core.app.ActivityCompat;
//
//import com.example.instantmessage.InstantMessageApplication;
//
//import java.util.ArrayList;
//import java.util.List;
//
//public class Utils {
//    private static final String TAG = Utils.class.getSimpleName();
//
//    public static final int REQ_PERMISSION_CODE = 0x100;
//
//    //权限检查
//    public static boolean checkPermission(Activity activity) {
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//            List<String> permissions = new ArrayList<>();
//            if (PackageManager.PERMISSION_GRANTED != ActivityCompat.checkSelfPermission(InstantMessageApplication.instance(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
//                permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
//            }
//            if (PackageManager.PERMISSION_GRANTED != ActivityCompat.checkSelfPermission(InstantMessageApplication.instance(), Manifest.permission.CAMERA)) {
//                permissions.add(Manifest.permission.CAMERA);
//            }
//            if (PackageManager.PERMISSION_GRANTED != ActivityCompat.checkSelfPermission(InstantMessageApplication.instance(), Manifest.permission.RECORD_AUDIO)) {
//                permissions.add(Manifest.permission.RECORD_AUDIO);
//            }
//            if (PackageManager.PERMISSION_GRANTED != ActivityCompat.checkSelfPermission(InstantMessageApplication.instance(), Manifest.permission.READ_PHONE_STATE)) {
//                permissions.add(Manifest.permission.READ_PHONE_STATE);
//            }
//            if (PackageManager.PERMISSION_GRANTED != ActivityCompat.checkSelfPermission(InstantMessageApplication.instance(), Manifest.permission.READ_EXTERNAL_STORAGE)) {
//                permissions.add(Manifest.permission.READ_EXTERNAL_STORAGE);
//            }
//            if (permissions.size() != 0) {
//                String[] permissionsArray = permissions.toArray(new String[1]);
//                ActivityCompat.requestPermissions(activity,
//                        permissionsArray,
//                        REQ_PERMISSION_CODE);
//                return false;
//            }
//        }
//
//        return true;
//    }
//}
